{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Imports"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "/usr/local/lib/python3.6/site-packages/h5py/__init__.py:36: FutureWarning: Conversion of the second argument of issubdtype from `float` to `np.floating` is deprecated. In future, it will be treated as `np.float64 == np.dtype(float).type`.\n",
      "  from ._conv import register_converters as _register_converters\n",
      "Using TensorFlow backend.\n"
     ]
    }
   ],
   "source": [
    "from IPython.display import SVG\n",
    "from keras.utils.vis_utils import model_to_dot"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [],
   "source": [
    "import base\n",
    "from src.models import build_deep_q_model"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Architecture"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [],
   "source": [
    "model = build_deep_q_model()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/svg+xml": [
       "<svg height=\"1025pt\" viewBox=\"0.00 0.00 449.46 1025.00\" width=\"449pt\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\">\n",
       "<g class=\"graph\" id=\"graph0\" transform=\"scale(1 1) rotate(0) translate(4 1021)\">\n",
       "<title>G</title>\n",
       "<polygon fill=\"#ffffff\" points=\"-4,4 -4,-1021 445.4624,-1021 445.4624,4 -4,4\" stroke=\"transparent\"/>\n",
       "<!-- 4803004960 -->\n",
       "<g class=\"node\" id=\"node1\">\n",
       "<title>4803004960</title>\n",
       "<polygon fill=\"none\" points=\"1.9517,-972.5 1.9517,-1016.5 247.4624,-1016.5 247.4624,-972.5 1.9517,-972.5\" stroke=\"#000000\"/>\n",
       "<text fill=\"#000000\" font-family=\"Times,serif\" font-size=\"14.00\" text-anchor=\"middle\" x=\"41.0483\" y=\"-990.3\">InputLayer</text>\n",
       "<polyline fill=\"none\" points=\"80.145,-972.5 80.145,-1016.5 \" stroke=\"#000000\"/>\n",
       "<text fill=\"#000000\" font-family=\"Times,serif\" font-size=\"14.00\" text-anchor=\"middle\" x=\"107.9795\" y=\"-1001.3\">input:</text>\n",
       "<polyline fill=\"none\" points=\"80.145,-994.5 135.814,-994.5 \" stroke=\"#000000\"/>\n",
       "<text fill=\"#000000\" font-family=\"Times,serif\" font-size=\"14.00\" text-anchor=\"middle\" x=\"107.9795\" y=\"-979.3\">output:</text>\n",
       "<polyline fill=\"none\" points=\"135.814,-972.5 135.814,-1016.5 \" stroke=\"#000000\"/>\n",
       "<text fill=\"#000000\" font-family=\"Times,serif\" font-size=\"14.00\" text-anchor=\"middle\" x=\"191.6382\" y=\"-1001.3\">(None, 84, 84, 4)</text>\n",
       "<polyline fill=\"none\" points=\"135.814,-994.5 247.4624,-994.5 \" stroke=\"#000000\"/>\n",
       "<text fill=\"#000000\" font-family=\"Times,serif\" font-size=\"14.00\" text-anchor=\"middle\" x=\"191.6382\" y=\"-979.3\">(None, 84, 84, 4)</text>\n",
       "</g>\n",
       "<!-- 4803003504 -->\n",
       "<g class=\"node\" id=\"node2\">\n",
       "<title>4803003504</title>\n",
       "<polygon fill=\"none\" points=\"10.1138,-891.5 10.1138,-935.5 239.3003,-935.5 239.3003,-891.5 10.1138,-891.5\" stroke=\"#000000\"/>\n",
       "<text fill=\"#000000\" font-family=\"Times,serif\" font-size=\"14.00\" text-anchor=\"middle\" x=\"41.0483\" y=\"-909.3\">Lambda</text>\n",
       "<polyline fill=\"none\" points=\"71.9829,-891.5 71.9829,-935.5 \" stroke=\"#000000\"/>\n",
       "<text fill=\"#000000\" font-family=\"Times,serif\" font-size=\"14.00\" text-anchor=\"middle\" x=\"99.8174\" y=\"-920.3\">input:</text>\n",
       "<polyline fill=\"none\" points=\"71.9829,-913.5 127.6519,-913.5 \" stroke=\"#000000\"/>\n",
       "<text fill=\"#000000\" font-family=\"Times,serif\" font-size=\"14.00\" text-anchor=\"middle\" x=\"99.8174\" y=\"-898.3\">output:</text>\n",
       "<polyline fill=\"none\" points=\"127.6519,-891.5 127.6519,-935.5 \" stroke=\"#000000\"/>\n",
       "<text fill=\"#000000\" font-family=\"Times,serif\" font-size=\"14.00\" text-anchor=\"middle\" x=\"183.4761\" y=\"-920.3\">(None, 84, 84, 4)</text>\n",
       "<polyline fill=\"none\" points=\"127.6519,-913.5 239.3003,-913.5 \" stroke=\"#000000\"/>\n",
       "<text fill=\"#000000\" font-family=\"Times,serif\" font-size=\"14.00\" text-anchor=\"middle\" x=\"183.4761\" y=\"-898.3\">(None, 84, 84, 4)</text>\n",
       "</g>\n",
       "<!-- 4803004960&#45;&gt;4803003504 -->\n",
       "<g class=\"edge\" id=\"edge1\">\n",
       "<title>4803004960-&gt;4803003504</title>\n",
       "<path d=\"M124.707,-972.3664C124.707,-964.1516 124.707,-954.6579 124.707,-945.7252\" fill=\"none\" stroke=\"#000000\"/>\n",
       "<polygon fill=\"#000000\" points=\"128.2071,-945.6068 124.707,-935.6068 121.2071,-945.6069 128.2071,-945.6068\" stroke=\"#000000\"/>\n",
       "</g>\n",
       "<!-- 4803234840 -->\n",
       "<g class=\"node\" id=\"node3\">\n",
       "<title>4803234840</title>\n",
       "<polygon fill=\"none\" points=\"5.8242,-810.5 5.8242,-854.5 243.5898,-854.5 243.5898,-810.5 5.8242,-810.5\" stroke=\"#000000\"/>\n",
       "<text fill=\"#000000\" font-family=\"Times,serif\" font-size=\"14.00\" text-anchor=\"middle\" x=\"37.5483\" y=\"-828.3\">Conv2D</text>\n",
       "<polyline fill=\"none\" points=\"69.2725,-810.5 69.2725,-854.5 \" stroke=\"#000000\"/>\n",
       "<text fill=\"#000000\" font-family=\"Times,serif\" font-size=\"14.00\" text-anchor=\"middle\" x=\"97.1069\" y=\"-839.3\">input:</text>\n",
       "<polyline fill=\"none\" points=\"69.2725,-832.5 124.9414,-832.5 \" stroke=\"#000000\"/>\n",
       "<text fill=\"#000000\" font-family=\"Times,serif\" font-size=\"14.00\" text-anchor=\"middle\" x=\"97.1069\" y=\"-817.3\">output:</text>\n",
       "<polyline fill=\"none\" points=\"124.9414,-810.5 124.9414,-854.5 \" stroke=\"#000000\"/>\n",
       "<text fill=\"#000000\" font-family=\"Times,serif\" font-size=\"14.00\" text-anchor=\"middle\" x=\"184.2656\" y=\"-839.3\">(None, 84, 84, 4)</text>\n",
       "<polyline fill=\"none\" points=\"124.9414,-832.5 243.5898,-832.5 \" stroke=\"#000000\"/>\n",
       "<text fill=\"#000000\" font-family=\"Times,serif\" font-size=\"14.00\" text-anchor=\"middle\" x=\"184.2656\" y=\"-817.3\">(None, 21, 21, 32)</text>\n",
       "</g>\n",
       "<!-- 4803003504&#45;&gt;4803234840 -->\n",
       "<g class=\"edge\" id=\"edge2\">\n",
       "<title>4803003504-&gt;4803234840</title>\n",
       "<path d=\"M124.707,-891.3664C124.707,-883.1516 124.707,-873.6579 124.707,-864.7252\" fill=\"none\" stroke=\"#000000\"/>\n",
       "<polygon fill=\"#000000\" points=\"128.2071,-864.6068 124.707,-854.6068 121.2071,-864.6069 128.2071,-864.6068\" stroke=\"#000000\"/>\n",
       "</g>\n",
       "<!-- 4803365464 -->\n",
       "<g class=\"node\" id=\"node4\">\n",
       "<title>4803365464</title>\n",
       "<polygon fill=\"none\" points=\"0,-729.5 0,-773.5 249.4141,-773.5 249.4141,-729.5 0,-729.5\" stroke=\"#000000\"/>\n",
       "<text fill=\"#000000\" font-family=\"Times,serif\" font-size=\"14.00\" text-anchor=\"middle\" x=\"37.5483\" y=\"-747.3\">Activation</text>\n",
       "<polyline fill=\"none\" points=\"75.0967,-729.5 75.0967,-773.5 \" stroke=\"#000000\"/>\n",
       "<text fill=\"#000000\" font-family=\"Times,serif\" font-size=\"14.00\" text-anchor=\"middle\" x=\"102.9312\" y=\"-758.3\">input:</text>\n",
       "<polyline fill=\"none\" points=\"75.0967,-751.5 130.7656,-751.5 \" stroke=\"#000000\"/>\n",
       "<text fill=\"#000000\" font-family=\"Times,serif\" font-size=\"14.00\" text-anchor=\"middle\" x=\"102.9312\" y=\"-736.3\">output:</text>\n",
       "<polyline fill=\"none\" points=\"130.7656,-729.5 130.7656,-773.5 \" stroke=\"#000000\"/>\n",
       "<text fill=\"#000000\" font-family=\"Times,serif\" font-size=\"14.00\" text-anchor=\"middle\" x=\"190.0898\" y=\"-758.3\">(None, 21, 21, 32)</text>\n",
       "<polyline fill=\"none\" points=\"130.7656,-751.5 249.4141,-751.5 \" stroke=\"#000000\"/>\n",
       "<text fill=\"#000000\" font-family=\"Times,serif\" font-size=\"14.00\" text-anchor=\"middle\" x=\"190.0898\" y=\"-736.3\">(None, 21, 21, 32)</text>\n",
       "</g>\n",
       "<!-- 4803234840&#45;&gt;4803365464 -->\n",
       "<g class=\"edge\" id=\"edge3\">\n",
       "<title>4803234840-&gt;4803365464</title>\n",
       "<path d=\"M124.707,-810.3664C124.707,-802.1516 124.707,-792.6579 124.707,-783.7252\" fill=\"none\" stroke=\"#000000\"/>\n",
       "<polygon fill=\"#000000\" points=\"128.2071,-783.6068 124.707,-773.6068 121.2071,-783.6069 128.2071,-783.6068\" stroke=\"#000000\"/>\n",
       "</g>\n",
       "<!-- 4803507368 -->\n",
       "<g class=\"node\" id=\"node5\">\n",
       "<title>4803507368</title>\n",
       "<polygon fill=\"none\" points=\"5.8242,-648.5 5.8242,-692.5 243.5898,-692.5 243.5898,-648.5 5.8242,-648.5\" stroke=\"#000000\"/>\n",
       "<text fill=\"#000000\" font-family=\"Times,serif\" font-size=\"14.00\" text-anchor=\"middle\" x=\"37.5483\" y=\"-666.3\">Conv2D</text>\n",
       "<polyline fill=\"none\" points=\"69.2725,-648.5 69.2725,-692.5 \" stroke=\"#000000\"/>\n",
       "<text fill=\"#000000\" font-family=\"Times,serif\" font-size=\"14.00\" text-anchor=\"middle\" x=\"97.1069\" y=\"-677.3\">input:</text>\n",
       "<polyline fill=\"none\" points=\"69.2725,-670.5 124.9414,-670.5 \" stroke=\"#000000\"/>\n",
       "<text fill=\"#000000\" font-family=\"Times,serif\" font-size=\"14.00\" text-anchor=\"middle\" x=\"97.1069\" y=\"-655.3\">output:</text>\n",
       "<polyline fill=\"none\" points=\"124.9414,-648.5 124.9414,-692.5 \" stroke=\"#000000\"/>\n",
       "<text fill=\"#000000\" font-family=\"Times,serif\" font-size=\"14.00\" text-anchor=\"middle\" x=\"184.2656\" y=\"-677.3\">(None, 21, 21, 32)</text>\n",
       "<polyline fill=\"none\" points=\"124.9414,-670.5 243.5898,-670.5 \" stroke=\"#000000\"/>\n",
       "<text fill=\"#000000\" font-family=\"Times,serif\" font-size=\"14.00\" text-anchor=\"middle\" x=\"184.2529\" y=\"-655.3\">(None, 11, 11, 64)</text>\n",
       "</g>\n",
       "<!-- 4803365464&#45;&gt;4803507368 -->\n",
       "<g class=\"edge\" id=\"edge4\">\n",
       "<title>4803365464-&gt;4803507368</title>\n",
       "<path d=\"M124.707,-729.3664C124.707,-721.1516 124.707,-711.6579 124.707,-702.7252\" fill=\"none\" stroke=\"#000000\"/>\n",
       "<polygon fill=\"#000000\" points=\"128.2071,-702.6068 124.707,-692.6068 121.2071,-702.6069 128.2071,-702.6068\" stroke=\"#000000\"/>\n",
       "</g>\n",
       "<!-- 4803509664 -->\n",
       "<g class=\"node\" id=\"node6\">\n",
       "<title>4803509664</title>\n",
       "<polygon fill=\"none\" points=\".5127,-567.5 .5127,-611.5 248.9014,-611.5 248.9014,-567.5 .5127,-567.5\" stroke=\"#000000\"/>\n",
       "<text fill=\"#000000\" font-family=\"Times,serif\" font-size=\"14.00\" text-anchor=\"middle\" x=\"38.061\" y=\"-585.3\">Activation</text>\n",
       "<polyline fill=\"none\" points=\"75.6094,-567.5 75.6094,-611.5 \" stroke=\"#000000\"/>\n",
       "<text fill=\"#000000\" font-family=\"Times,serif\" font-size=\"14.00\" text-anchor=\"middle\" x=\"103.4438\" y=\"-596.3\">input:</text>\n",
       "<polyline fill=\"none\" points=\"75.6094,-589.5 131.2783,-589.5 \" stroke=\"#000000\"/>\n",
       "<text fill=\"#000000\" font-family=\"Times,serif\" font-size=\"14.00\" text-anchor=\"middle\" x=\"103.4438\" y=\"-574.3\">output:</text>\n",
       "<polyline fill=\"none\" points=\"131.2783,-567.5 131.2783,-611.5 \" stroke=\"#000000\"/>\n",
       "<text fill=\"#000000\" font-family=\"Times,serif\" font-size=\"14.00\" text-anchor=\"middle\" x=\"190.0898\" y=\"-596.3\">(None, 11, 11, 64)</text>\n",
       "<polyline fill=\"none\" points=\"131.2783,-589.5 248.9014,-589.5 \" stroke=\"#000000\"/>\n",
       "<text fill=\"#000000\" font-family=\"Times,serif\" font-size=\"14.00\" text-anchor=\"middle\" x=\"190.0898\" y=\"-574.3\">(None, 11, 11, 64)</text>\n",
       "</g>\n",
       "<!-- 4803507368&#45;&gt;4803509664 -->\n",
       "<g class=\"edge\" id=\"edge5\">\n",
       "<title>4803507368-&gt;4803509664</title>\n",
       "<path d=\"M124.707,-648.3664C124.707,-640.1516 124.707,-630.6579 124.707,-621.7252\" fill=\"none\" stroke=\"#000000\"/>\n",
       "<polygon fill=\"#000000\" points=\"128.2071,-621.6068 124.707,-611.6068 121.2071,-621.6069 128.2071,-621.6068\" stroke=\"#000000\"/>\n",
       "</g>\n",
       "<!-- 4803781352 -->\n",
       "<g class=\"node\" id=\"node7\">\n",
       "<title>4803781352</title>\n",
       "<polygon fill=\"none\" points=\"6.3369,-486.5 6.3369,-530.5 243.0771,-530.5 243.0771,-486.5 6.3369,-486.5\" stroke=\"#000000\"/>\n",
       "<text fill=\"#000000\" font-family=\"Times,serif\" font-size=\"14.00\" text-anchor=\"middle\" x=\"38.061\" y=\"-504.3\">Conv2D</text>\n",
       "<polyline fill=\"none\" points=\"69.7852,-486.5 69.7852,-530.5 \" stroke=\"#000000\"/>\n",
       "<text fill=\"#000000\" font-family=\"Times,serif\" font-size=\"14.00\" text-anchor=\"middle\" x=\"97.6196\" y=\"-515.3\">input:</text>\n",
       "<polyline fill=\"none\" points=\"69.7852,-508.5 125.4541,-508.5 \" stroke=\"#000000\"/>\n",
       "<text fill=\"#000000\" font-family=\"Times,serif\" font-size=\"14.00\" text-anchor=\"middle\" x=\"97.6196\" y=\"-493.3\">output:</text>\n",
       "<polyline fill=\"none\" points=\"125.4541,-486.5 125.4541,-530.5 \" stroke=\"#000000\"/>\n",
       "<text fill=\"#000000\" font-family=\"Times,serif\" font-size=\"14.00\" text-anchor=\"middle\" x=\"184.2656\" y=\"-515.3\">(None, 11, 11, 64)</text>\n",
       "<polyline fill=\"none\" points=\"125.4541,-508.5 243.0771,-508.5 \" stroke=\"#000000\"/>\n",
       "<text fill=\"#000000\" font-family=\"Times,serif\" font-size=\"14.00\" text-anchor=\"middle\" x=\"184.2656\" y=\"-493.3\">(None, 11, 11, 64)</text>\n",
       "</g>\n",
       "<!-- 4803509664&#45;&gt;4803781352 -->\n",
       "<g class=\"edge\" id=\"edge6\">\n",
       "<title>4803509664-&gt;4803781352</title>\n",
       "<path d=\"M124.707,-567.3664C124.707,-559.1516 124.707,-549.6579 124.707,-540.7252\" fill=\"none\" stroke=\"#000000\"/>\n",
       "<polygon fill=\"#000000\" points=\"128.2071,-540.6068 124.707,-530.6068 121.2071,-540.6069 128.2071,-540.6068\" stroke=\"#000000\"/>\n",
       "</g>\n",
       "<!-- 4803881560 -->\n",
       "<g class=\"node\" id=\"node8\">\n",
       "<title>4803881560</title>\n",
       "<polygon fill=\"none\" points=\".5127,-405.5 .5127,-449.5 248.9014,-449.5 248.9014,-405.5 .5127,-405.5\" stroke=\"#000000\"/>\n",
       "<text fill=\"#000000\" font-family=\"Times,serif\" font-size=\"14.00\" text-anchor=\"middle\" x=\"38.061\" y=\"-423.3\">Activation</text>\n",
       "<polyline fill=\"none\" points=\"75.6094,-405.5 75.6094,-449.5 \" stroke=\"#000000\"/>\n",
       "<text fill=\"#000000\" font-family=\"Times,serif\" font-size=\"14.00\" text-anchor=\"middle\" x=\"103.4438\" y=\"-434.3\">input:</text>\n",
       "<polyline fill=\"none\" points=\"75.6094,-427.5 131.2783,-427.5 \" stroke=\"#000000\"/>\n",
       "<text fill=\"#000000\" font-family=\"Times,serif\" font-size=\"14.00\" text-anchor=\"middle\" x=\"103.4438\" y=\"-412.3\">output:</text>\n",
       "<polyline fill=\"none\" points=\"131.2783,-405.5 131.2783,-449.5 \" stroke=\"#000000\"/>\n",
       "<text fill=\"#000000\" font-family=\"Times,serif\" font-size=\"14.00\" text-anchor=\"middle\" x=\"190.0898\" y=\"-434.3\">(None, 11, 11, 64)</text>\n",
       "<polyline fill=\"none\" points=\"131.2783,-427.5 248.9014,-427.5 \" stroke=\"#000000\"/>\n",
       "<text fill=\"#000000\" font-family=\"Times,serif\" font-size=\"14.00\" text-anchor=\"middle\" x=\"190.0898\" y=\"-412.3\">(None, 11, 11, 64)</text>\n",
       "</g>\n",
       "<!-- 4803781352&#45;&gt;4803881560 -->\n",
       "<g class=\"edge\" id=\"edge7\">\n",
       "<title>4803781352-&gt;4803881560</title>\n",
       "<path d=\"M124.707,-486.3664C124.707,-478.1516 124.707,-468.6579 124.707,-459.7252\" fill=\"none\" stroke=\"#000000\"/>\n",
       "<polygon fill=\"#000000\" points=\"128.2071,-459.6068 124.707,-449.6068 121.2071,-459.6069 128.2071,-459.6068\" stroke=\"#000000\"/>\n",
       "</g>\n",
       "<!-- 4803961184 -->\n",
       "<g class=\"node\" id=\"node9\">\n",
       "<title>4803961184</title>\n",
       "<polygon fill=\"none\" points=\"10.6196,-324.5 10.6196,-368.5 238.7944,-368.5 238.7944,-324.5 10.6196,-324.5\" stroke=\"#000000\"/>\n",
       "<text fill=\"#000000\" font-family=\"Times,serif\" font-size=\"14.00\" text-anchor=\"middle\" x=\"38.061\" y=\"-342.3\">Flatten</text>\n",
       "<polyline fill=\"none\" points=\"65.5024,-324.5 65.5024,-368.5 \" stroke=\"#000000\"/>\n",
       "<text fill=\"#000000\" font-family=\"Times,serif\" font-size=\"14.00\" text-anchor=\"middle\" x=\"93.3369\" y=\"-353.3\">input:</text>\n",
       "<polyline fill=\"none\" points=\"65.5024,-346.5 121.1714,-346.5 \" stroke=\"#000000\"/>\n",
       "<text fill=\"#000000\" font-family=\"Times,serif\" font-size=\"14.00\" text-anchor=\"middle\" x=\"93.3369\" y=\"-331.3\">output:</text>\n",
       "<polyline fill=\"none\" points=\"121.1714,-324.5 121.1714,-368.5 \" stroke=\"#000000\"/>\n",
       "<text fill=\"#000000\" font-family=\"Times,serif\" font-size=\"14.00\" text-anchor=\"middle\" x=\"179.9829\" y=\"-353.3\">(None, 11, 11, 64)</text>\n",
       "<polyline fill=\"none\" points=\"121.1714,-346.5 238.7944,-346.5 \" stroke=\"#000000\"/>\n",
       "<text fill=\"#000000\" font-family=\"Times,serif\" font-size=\"14.00\" text-anchor=\"middle\" x=\"179.4956\" y=\"-331.3\">(None, 7744)</text>\n",
       "</g>\n",
       "<!-- 4803881560&#45;&gt;4803961184 -->\n",
       "<g class=\"edge\" id=\"edge8\">\n",
       "<title>4803881560-&gt;4803961184</title>\n",
       "<path d=\"M124.707,-405.3664C124.707,-397.1516 124.707,-387.6579 124.707,-378.7252\" fill=\"none\" stroke=\"#000000\"/>\n",
       "<polygon fill=\"#000000\" points=\"128.2071,-378.6068 124.707,-368.6068 121.2071,-378.6069 128.2071,-378.6068\" stroke=\"#000000\"/>\n",
       "</g>\n",
       "<!-- 4803961016 -->\n",
       "<g class=\"node\" id=\"node10\">\n",
       "<title>4803961016</title>\n",
       "<polygon fill=\"none\" points=\"26.0552,-243.5 26.0552,-287.5 223.3589,-287.5 223.3589,-243.5 26.0552,-243.5\" stroke=\"#000000\"/>\n",
       "<text fill=\"#000000\" font-family=\"Times,serif\" font-size=\"14.00\" text-anchor=\"middle\" x=\"51.5483\" y=\"-261.3\">Dense</text>\n",
       "<polyline fill=\"none\" points=\"77.0415,-243.5 77.0415,-287.5 \" stroke=\"#000000\"/>\n",
       "<text fill=\"#000000\" font-family=\"Times,serif\" font-size=\"14.00\" text-anchor=\"middle\" x=\"104.876\" y=\"-272.3\">input:</text>\n",
       "<polyline fill=\"none\" points=\"77.0415,-265.5 132.7104,-265.5 \" stroke=\"#000000\"/>\n",
       "<text fill=\"#000000\" font-family=\"Times,serif\" font-size=\"14.00\" text-anchor=\"middle\" x=\"104.876\" y=\"-250.3\">output:</text>\n",
       "<polyline fill=\"none\" points=\"132.7104,-243.5 132.7104,-287.5 \" stroke=\"#000000\"/>\n",
       "<text fill=\"#000000\" font-family=\"Times,serif\" font-size=\"14.00\" text-anchor=\"middle\" x=\"178.0347\" y=\"-272.3\">(None, 7744)</text>\n",
       "<polyline fill=\"none\" points=\"132.7104,-265.5 223.3589,-265.5 \" stroke=\"#000000\"/>\n",
       "<text fill=\"#000000\" font-family=\"Times,serif\" font-size=\"14.00\" text-anchor=\"middle\" x=\"178.0347\" y=\"-250.3\">(None, 512)</text>\n",
       "</g>\n",
       "<!-- 4803961184&#45;&gt;4803961016 -->\n",
       "<g class=\"edge\" id=\"edge9\">\n",
       "<title>4803961184-&gt;4803961016</title>\n",
       "<path d=\"M124.707,-324.3664C124.707,-316.1516 124.707,-306.6579 124.707,-297.7252\" fill=\"none\" stroke=\"#000000\"/>\n",
       "<polygon fill=\"#000000\" points=\"128.2071,-297.6068 124.707,-287.6068 121.2071,-297.6069 128.2071,-297.6068\" stroke=\"#000000\"/>\n",
       "</g>\n",
       "<!-- 4804229104 -->\n",
       "<g class=\"node\" id=\"node11\">\n",
       "<title>4804229104</title>\n",
       "<polygon fill=\"none\" points=\"17.5,-162.5 17.5,-206.5 231.9141,-206.5 231.9141,-162.5 17.5,-162.5\" stroke=\"#000000\"/>\n",
       "<text fill=\"#000000\" font-family=\"Times,serif\" font-size=\"14.00\" text-anchor=\"middle\" x=\"55.0483\" y=\"-180.3\">Activation</text>\n",
       "<polyline fill=\"none\" points=\"92.5967,-162.5 92.5967,-206.5 \" stroke=\"#000000\"/>\n",
       "<text fill=\"#000000\" font-family=\"Times,serif\" font-size=\"14.00\" text-anchor=\"middle\" x=\"120.4312\" y=\"-191.3\">input:</text>\n",
       "<polyline fill=\"none\" points=\"92.5967,-184.5 148.2656,-184.5 \" stroke=\"#000000\"/>\n",
       "<text fill=\"#000000\" font-family=\"Times,serif\" font-size=\"14.00\" text-anchor=\"middle\" x=\"120.4312\" y=\"-169.3\">output:</text>\n",
       "<polyline fill=\"none\" points=\"148.2656,-162.5 148.2656,-206.5 \" stroke=\"#000000\"/>\n",
       "<text fill=\"#000000\" font-family=\"Times,serif\" font-size=\"14.00\" text-anchor=\"middle\" x=\"190.0898\" y=\"-191.3\">(None, 512)</text>\n",
       "<polyline fill=\"none\" points=\"148.2656,-184.5 231.9141,-184.5 \" stroke=\"#000000\"/>\n",
       "<text fill=\"#000000\" font-family=\"Times,serif\" font-size=\"14.00\" text-anchor=\"middle\" x=\"190.0898\" y=\"-169.3\">(None, 512)</text>\n",
       "</g>\n",
       "<!-- 4803961016&#45;&gt;4804229104 -->\n",
       "<g class=\"edge\" id=\"edge10\">\n",
       "<title>4803961016-&gt;4804229104</title>\n",
       "<path d=\"M124.707,-243.3664C124.707,-235.1516 124.707,-225.6579 124.707,-216.7252\" fill=\"none\" stroke=\"#000000\"/>\n",
       "<polygon fill=\"#000000\" points=\"128.2071,-216.6068 124.707,-206.6068 121.2071,-216.6069 128.2071,-216.6068\" stroke=\"#000000\"/>\n",
       "</g>\n",
       "<!-- 4804227648 -->\n",
       "<g class=\"node\" id=\"node12\">\n",
       "<title>4804227648</title>\n",
       "<polygon fill=\"none\" points=\"29.5552,-81.5 29.5552,-125.5 219.8589,-125.5 219.8589,-81.5 29.5552,-81.5\" stroke=\"#000000\"/>\n",
       "<text fill=\"#000000\" font-family=\"Times,serif\" font-size=\"14.00\" text-anchor=\"middle\" x=\"55.0483\" y=\"-99.3\">Dense</text>\n",
       "<polyline fill=\"none\" points=\"80.5415,-81.5 80.5415,-125.5 \" stroke=\"#000000\"/>\n",
       "<text fill=\"#000000\" font-family=\"Times,serif\" font-size=\"14.00\" text-anchor=\"middle\" x=\"108.376\" y=\"-110.3\">input:</text>\n",
       "<polyline fill=\"none\" points=\"80.5415,-103.5 136.2104,-103.5 \" stroke=\"#000000\"/>\n",
       "<text fill=\"#000000\" font-family=\"Times,serif\" font-size=\"14.00\" text-anchor=\"middle\" x=\"108.376\" y=\"-88.3\">output:</text>\n",
       "<polyline fill=\"none\" points=\"136.2104,-81.5 136.2104,-125.5 \" stroke=\"#000000\"/>\n",
       "<text fill=\"#000000\" font-family=\"Times,serif\" font-size=\"14.00\" text-anchor=\"middle\" x=\"178.0347\" y=\"-110.3\">(None, 512)</text>\n",
       "<polyline fill=\"none\" points=\"136.2104,-103.5 219.8589,-103.5 \" stroke=\"#000000\"/>\n",
       "<text fill=\"#000000\" font-family=\"Times,serif\" font-size=\"14.00\" text-anchor=\"middle\" x=\"178.0347\" y=\"-88.3\">(None, 6)</text>\n",
       "</g>\n",
       "<!-- 4804229104&#45;&gt;4804227648 -->\n",
       "<g class=\"edge\" id=\"edge11\">\n",
       "<title>4804229104-&gt;4804227648</title>\n",
       "<path d=\"M124.707,-162.3664C124.707,-154.1516 124.707,-144.6579 124.707,-135.7252\" fill=\"none\" stroke=\"#000000\"/>\n",
       "<polygon fill=\"#000000\" points=\"128.2071,-135.6068 124.707,-125.6068 121.2071,-135.6069 128.2071,-135.6068\" stroke=\"#000000\"/>\n",
       "</g>\n",
       "<!-- 4804331392 -->\n",
       "<g class=\"node\" id=\"node14\">\n",
       "<title>4804331392</title>\n",
       "<polygon fill=\"none\" points=\"101.5586,-.5 101.5586,-44.5 361.8555,-44.5 361.8555,-.5 101.5586,-.5\" stroke=\"#000000\"/>\n",
       "<text fill=\"#000000\" font-family=\"Times,serif\" font-size=\"14.00\" text-anchor=\"middle\" x=\"134.062\" y=\"-18.3\">Multiply</text>\n",
       "<polyline fill=\"none\" points=\"166.5654,-.5 166.5654,-44.5 \" stroke=\"#000000\"/>\n",
       "<text fill=\"#000000\" font-family=\"Times,serif\" font-size=\"14.00\" text-anchor=\"middle\" x=\"194.3999\" y=\"-29.3\">input:</text>\n",
       "<polyline fill=\"none\" points=\"166.5654,-22.5 222.2344,-22.5 \" stroke=\"#000000\"/>\n",
       "<text fill=\"#000000\" font-family=\"Times,serif\" font-size=\"14.00\" text-anchor=\"middle\" x=\"194.3999\" y=\"-7.3\">output:</text>\n",
       "<polyline fill=\"none\" points=\"222.2344,-.5 222.2344,-44.5 \" stroke=\"#000000\"/>\n",
       "<text fill=\"#000000\" font-family=\"Times,serif\" font-size=\"14.00\" text-anchor=\"middle\" x=\"292.0449\" y=\"-29.3\">[(None, 6), (None, 6)]</text>\n",
       "<polyline fill=\"none\" points=\"222.2344,-22.5 361.8555,-22.5 \" stroke=\"#000000\"/>\n",
       "<text fill=\"#000000\" font-family=\"Times,serif\" font-size=\"14.00\" text-anchor=\"middle\" x=\"291.5586\" y=\"-7.3\">(None, 6)</text>\n",
       "</g>\n",
       "<!-- 4804227648&#45;&gt;4804331392 -->\n",
       "<g class=\"edge\" id=\"edge12\">\n",
       "<title>4804227648-&gt;4804331392</title>\n",
       "<path d=\"M153.9453,-81.3664C166.4482,-71.9016 181.1939,-60.7389 194.4649,-50.6926\" fill=\"none\" stroke=\"#000000\"/>\n",
       "<polygon fill=\"#000000\" points=\"196.6436,-53.4332 202.5042,-44.6068 192.4185,-47.852 196.6436,-53.4332\" stroke=\"#000000\"/>\n",
       "</g>\n",
       "<!-- 4804331336 -->\n",
       "<g class=\"node\" id=\"node13\">\n",
       "<title>4804331336</title>\n",
       "<polygon fill=\"none\" points=\"237.9517,-81.5 237.9517,-125.5 441.4624,-125.5 441.4624,-81.5 237.9517,-81.5\" stroke=\"#000000\"/>\n",
       "<text fill=\"#000000\" font-family=\"Times,serif\" font-size=\"14.00\" text-anchor=\"middle\" x=\"277.0483\" y=\"-99.3\">InputLayer</text>\n",
       "<polyline fill=\"none\" points=\"316.145,-81.5 316.145,-125.5 \" stroke=\"#000000\"/>\n",
       "<text fill=\"#000000\" font-family=\"Times,serif\" font-size=\"14.00\" text-anchor=\"middle\" x=\"343.9795\" y=\"-110.3\">input:</text>\n",
       "<polyline fill=\"none\" points=\"316.145,-103.5 371.814,-103.5 \" stroke=\"#000000\"/>\n",
       "<text fill=\"#000000\" font-family=\"Times,serif\" font-size=\"14.00\" text-anchor=\"middle\" x=\"343.9795\" y=\"-88.3\">output:</text>\n",
       "<polyline fill=\"none\" points=\"371.814,-81.5 371.814,-125.5 \" stroke=\"#000000\"/>\n",
       "<text fill=\"#000000\" font-family=\"Times,serif\" font-size=\"14.00\" text-anchor=\"middle\" x=\"406.6382\" y=\"-110.3\">(None, 6)</text>\n",
       "<polyline fill=\"none\" points=\"371.814,-103.5 441.4624,-103.5 \" stroke=\"#000000\"/>\n",
       "<text fill=\"#000000\" font-family=\"Times,serif\" font-size=\"14.00\" text-anchor=\"middle\" x=\"406.6382\" y=\"-88.3\">(None, 6)</text>\n",
       "</g>\n",
       "<!-- 4804331336&#45;&gt;4804331392 -->\n",
       "<g class=\"edge\" id=\"edge13\">\n",
       "<title>4804331336-&gt;4804331392</title>\n",
       "<path d=\"M310.1956,-81.3664C297.5758,-71.9016 282.6922,-60.7389 269.2972,-50.6926\" fill=\"none\" stroke=\"#000000\"/>\n",
       "<polygon fill=\"#000000\" points=\"271.2829,-47.8069 261.1828,-44.6068 267.0828,-53.4069 271.2829,-47.8069\" stroke=\"#000000\"/>\n",
       "</g>\n",
       "</g>\n",
       "</svg>"
      ],
      "text/plain": [
       "<IPython.core.display.SVG object>"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "SVG(model_to_dot(model, show_shapes=True, show_layer_names=False).create(prog='dot', format='svg'))"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Summary"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "__________________________________________________________________________________________________\n",
      "Layer (type)                    Output Shape         Param #     Connected to                     \n",
      "==================================================================================================\n",
      "cnn (InputLayer)                (None, 84, 84, 4)    0                                            \n",
      "__________________________________________________________________________________________________\n",
      "lambda_1 (Lambda)               (None, 84, 84, 4)    0           cnn[0][0]                        \n",
      "__________________________________________________________________________________________________\n",
      "conv2d_1 (Conv2D)               (None, 21, 21, 32)   8224        lambda_1[0][0]                   \n",
      "__________________________________________________________________________________________________\n",
      "activation_1 (Activation)       (None, 21, 21, 32)   0           conv2d_1[0][0]                   \n",
      "__________________________________________________________________________________________________\n",
      "conv2d_2 (Conv2D)               (None, 11, 11, 64)   32832       activation_1[0][0]               \n",
      "__________________________________________________________________________________________________\n",
      "activation_2 (Activation)       (None, 11, 11, 64)   0           conv2d_2[0][0]                   \n",
      "__________________________________________________________________________________________________\n",
      "conv2d_3 (Conv2D)               (None, 11, 11, 64)   36928       activation_2[0][0]               \n",
      "__________________________________________________________________________________________________\n",
      "activation_3 (Activation)       (None, 11, 11, 64)   0           conv2d_3[0][0]                   \n",
      "__________________________________________________________________________________________________\n",
      "flatten_1 (Flatten)             (None, 7744)         0           activation_3[0][0]               \n",
      "__________________________________________________________________________________________________\n",
      "dense_1 (Dense)                 (None, 512)          3965440     flatten_1[0][0]                  \n",
      "__________________________________________________________________________________________________\n",
      "activation_4 (Activation)       (None, 512)          0           dense_1[0][0]                    \n",
      "__________________________________________________________________________________________________\n",
      "dense_2 (Dense)                 (None, 6)            3078        activation_4[0][0]               \n",
      "__________________________________________________________________________________________________\n",
      "mask (InputLayer)               (None, 6)            0                                            \n",
      "__________________________________________________________________________________________________\n",
      "multiply_1 (Multiply)           (None, 6)            0           dense_2[0][0]                    \n",
      "                                                                 mask[0][0]                       \n",
      "==================================================================================================\n",
      "Total params: 4,046,502\n",
      "Trainable params: 4,046,502\n",
      "Non-trainable params: 0\n",
      "__________________________________________________________________________________________________\n"
     ]
    }
   ],
   "source": [
    "model.summary()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    " "
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.4"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
